package JZ;

import java.util.ArrayList;

class ListNode {
    int val;
    ListNode next = null;

    public ListNode(int val) {
        this.val = val;
    }
}

public class JZ06 {
    public int[] reversePrint(ListNode head) {
        ArrayList<Integer> integers = new ArrayList<>();
        while (head!=null){
            integers.add(head.val);
            head = head.next;
        }
        int[] ints = new int[integers.size()];
        int index = 0;
        for (int i = integers.size()-1; i >= 0; i--) {
            ints[index++] = integers.get(i);
        }
        return ints;
    }
}
